package com.xbongbong.sys.model.impl;

import com.xbongbong.paas.toolbox.util.DateUtil;
import com.xbongbong.sys.domain.dao.DingTalkPayLogDao;
import com.xbongbong.sys.domain.entity.DingTalkPayLogEntity;
import com.xbongbong.sys.model.DingTalkPayLogModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @version v1.0
 * @param: $
 * @return: $
 * @auther: youli.chen
 * @date: $ $
 * @since v1.0
 */
@Service("dingTalkPayLogModel")
public class DingTalkPayLogModelImpl implements DingTalkPayLogModel {

    @Resource
    private DingTalkPayLogDao dingTalkPayLogDao;

    @Override
    public Integer insert(DingTalkPayLogEntity entity){
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);

        return dingTalkPayLogDao.insert(entity);
    }

    @Override
    public Integer update(DingTalkPayLogEntity entity){
        entity.setUpdateTime((long)DateUtil.getInt());

        return dingTalkPayLogDao.update(entity);
    }

    @Override
    public Integer save(DingTalkPayLogEntity entity){

        if(entity.getId() == null || Objects.equals(0L, entity.getId())) {
            return dingTalkPayLogDao.insert(entity);
        }
        return dingTalkPayLogDao.update(entity);
    }

    @Override
    public Integer deleteByKey( Long key){
        return dingTalkPayLogDao.deleteByKey(key);
    }

    @Override
    public DingTalkPayLogEntity getByKey( Long key){
        return dingTalkPayLogDao.getByKey(key);
    }

    @Override
    public List<DingTalkPayLogEntity> findEntitys(Map<String ,Object> param){
        return dingTalkPayLogDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String ,Object>  param){
        return dingTalkPayLogDao.getEntitysCount(param);
    }

    @Override
    public List<DingTalkPayLogEntity> getByOrderType(Integer orderType) {
        return dingTalkPayLogDao.getByType(orderType);
    }
}
